package demo.model;

import com.alibaba.fastjson.JSON;

/**
 * Redis应用端行为采集信息
 */
public class RedisProfiling {

    private String app_name;
    private String app_ip;
    private String app_host;
    // 执行命令开始时间
    private Long r_start;
    // 结束时间
    private Long r_end;
    // 执行命令类型、如get、set、hget、hset等各种
    private String r_cmd;
    // 访问Redis集群的服务器地址与端口，其中某一台ip:port
    private String r_instance;
    // 操作的KEY
    private String r_key;
    // 参数大小
    private Integer r_arg_size;
    // 返回数据大小
    private Integer r_value_size;

    /**
     * 耗时
     *
     * @return
     */
    public Long getCost() {
        if (r_start != null && r_end != null) {
            return r_end - r_start;
        }
        return null;
    }

    public String getApp_name() {
        return app_name;
    }

    public void setApp_name(String app_name) {
        this.app_name = app_name;
    }

    public String getApp_ip() {
        return app_ip;
    }

    public void setApp_ip(String app_ip) {
        this.app_ip = app_ip;
    }

    public String getApp_host() {
        return app_host;
    }

    public void setApp_host(String app_host) {
        this.app_host = app_host;
    }

    public Long getR_start() {
        return r_start;
    }

    public void setR_start(Long r_start) {
        this.r_start = r_start;
    }

    public Long getR_end() {
        return r_end;
    }

    public void setR_end(Long r_end) {
        this.r_end = r_end;
    }

    public String getR_cmd() {
        return r_cmd;
    }

    public void setR_cmd(String r_cmd) {
        this.r_cmd = r_cmd;
    }

    public String getR_instance() {
        return r_instance;
    }

    public void setR_instance(String r_instance) {
        this.r_instance = r_instance;
    }

    public String getR_key() {
        return r_key;
    }

    public void setR_key(String r_key) {
        this.r_key = r_key;
    }

    public Integer getR_arg_size() {
        return r_arg_size;
    }

    public void setR_arg_size(Integer r_arg_size) {
        this.r_arg_size = r_arg_size;
    }

    public Integer getR_value_size() {
        return r_value_size;
    }

    public void setR_value_size(Integer r_value_size) {
        this.r_value_size = r_value_size;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
